﻿using UnityEngine;
using System.Collections;

namespace MyUtils
{
    public enum CEventType
    {
        GAME_OVER,
        GAME_WIN,
        PAUSE,
        ENERGY_EMEPTY,
        GAME_DATA,

    }

    public class CBaseEvent
    {
        protected Hashtable arguments;
        protected CEventType type;
        protected object sender;



        /// <summary>
        /// Type属性
        /// </summary>
        public CEventType Type
        {
            get { return this.type; }
            set { this.type = value; }
        }

        public IDictionary Params//属性
        {
            get { return this.arguments; }
            set { this.arguments = (value as Hashtable); }
        }

        public object Sender//属性
        {
            get { return this.sender; }
            set { this.sender = value; }
        }

        public override string ToString()//重写ToString
        {
            return this.type + "[" + ((this.sender == null) ? "null" : this.sender.ToString()) + "]";
        }


        /// <summary>
        /// 克隆基类的方法
        /// </summary>
        /// <returns></returns>
        public CBaseEvent Clone()
        {
            return new CBaseEvent(this.type, this.arguments, Sender);
        }

        /// <summary>
        /// 三个参数的构造函数
        /// </summary>
        /// <param name="type">类型</param>
        /// <param name="args"></param>
        /// <param name="sender"></param>
        public CBaseEvent(CEventType type, Hashtable args, object sender)
        {
            this.Type = type;
            this.arguments = args;
            this.Sender = sender;
            if (this.arguments == null)
            {
                this.arguments = new Hashtable();
            }
        }

        /// <summary>
        /// 两个参数的构造函数
        /// </summary>
        /// <param name="type"></param>
        /// <param name="sender"></param>
        public CBaseEvent(CEventType type, object sender)
        {
            this.Type = type;
            Sender = sender;
            if (this.arguments == null)
            {
                this.arguments = new Hashtable();
            }
        }
    }
}